package com.wcl.application.spring.gateway;

import com.wcl.application.spring.gateway.config.MyLoadBalancerClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer;
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients(basePackages = "com.wcl.application.spring.gateway.sdk")
public class ApplicationSpringGateway {
    public static void main(String[] args) {
        try {
            SpringApplication.run(ApplicationSpringGateway.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Bean
    public BlockingLoadBalancerClient blockingLoadBalancerClient(ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerClientFactory) {
        return new MyLoadBalancerClient(loadBalancerClientFactory);
    }
}
